/// 关注关系数据模型
/// 包含用户之间的关注关系信息
class FollowRelationEntity {
  final String relationId;
  final String followerId; // 关注者ID
  final String followingId; // 被关注者ID
  final DateTime followTime; // 关注时间

  const FollowRelationEntity({
    required this.relationId,
    required this.followerId,
    required this.followingId,
    required this.followTime,
  });

  /// 从JSON创建关注关系对象
  factory FollowRelationEntity.fromJson(Map<String, dynamic> json) {
    return FollowRelationEntity(
      relationId: json['relationId'] as String,
      followerId: json['followerId'] as String,
      followingId: json['followingId'] as String,
      followTime: DateTime.parse(json['followTime'] as String),
    );
  }

  /// 转换为JSON
  Map<String, dynamic> toJson() {
    return {
      'relationId': relationId,
      'followerId': followerId,
      'followingId': followingId,
      'followTime': followTime.toIso8601String(),
    };
  }

  /// 复制关注关系对象并修改部分属性
  FollowRelationEntity copyWith({
    String? relationId,
    String? followerId,
    String? followingId,
    DateTime? followTime,
  }) {
    return FollowRelationEntity(
      relationId: relationId ?? this.relationId,
      followerId: followerId ?? this.followerId,
      followingId: followingId ?? this.followingId,
      followTime: followTime ?? this.followTime,
    );
  }

  @override
  String toString() {
    return 'FollowRelationEntity(relationId: $relationId, followerId: $followerId, followingId: $followingId, followTime: $followTime)';
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;
    return other is FollowRelationEntity && other.relationId == relationId;
  }

  @override
  int get hashCode => relationId.hashCode;
}
